<!--
 * @Author: your name
 * @Date: 2021-07-08 11:13:29
 * @LastEditTime: 2021-07-10 19:48:47
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \vue-hr-project\src\test\1.html
-->
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        // const a = [
        //     {
        //         id:1,
        //         value:'正式'
        //     },
        //     {
        //         id:2,
        //         value:'非正式'
        //     }
        // ]
        // function b(d){
        //     let c = {}
        //     d.forEach(item => {
        //         c[item.id] =item.value
        //     })
        //     return c
        // }
        // console.log(b(a));
        const obj = {1:'正式',2:'非正式'}
        function transArray(sourceObj){
            let arr = []
            Object.keys(sourceObj).forEach(key=>{
                arr.push({
                    id: key,
                    value: sourceObj[key]
                })
            })
            return arr
        }
        console.log(transArray(obj));
    </script>
</body>
</html>